//
//  TimeHeader.m
//  timelyRain
//
//  Created by Jiafei Wei on 16/9/5.
//  Copyright © 2016年 Jiafei Wei. All rights reserved.
//

#import "TimeHeader.h"
#import "MBTPre.h"
@interface TimeHeader()<UIGestureRecognizerDelegate>

@end
@implementation TimeHeader

+ (instancetype)headerView
{
    TimeHeader *headerView = [[[NSBundle mainBundle] loadNibNamed:@"TimeHeader" owner:nil options:nil] lastObject];
    CGRect frame = headerView.frame;
    frame.size.width=SCREEN_W;//重新设定
    headerView.frame =frame;
    return headerView;
}


//当xib中的控件加载完成会调用此方法
- (void)awakeFromNib
{
    [self rightTo];
    [self backTo];
}
-(void)rightTo{
    _right.userInteractionEnabled = YES;
    UITapGestureRecognizer *addTapGest = [[UITapGestureRecognizer alloc] init];
    addTapGest.numberOfTapsRequired = 1;
    addTapGest.delegate = self;
    [_right addGestureRecognizer:addTapGest];
    [addTapGest addTarget:self action:@selector(rightTapView:)];
}
- (void)rightTapView:(UITapGestureRecognizer *)addTapGest{
    if ([self.delegate respondsToSelector:@selector(right)]) {
        [self.delegate right];
    }
}
-(void)backTo{
    _backView.userInteractionEnabled = YES;
    UITapGestureRecognizer *addTapGest = [[UITapGestureRecognizer alloc] init];
    addTapGest.numberOfTapsRequired = 1;
    addTapGest.delegate = self;
    [_backView addGestureRecognizer:addTapGest];
    [addTapGest addTarget:self action:@selector(backTapView:)];
}
- (void)backTapView:(UITapGestureRecognizer *)addTapGest{
    if ([self.delegate respondsToSelector:@selector(back)]) {
        [self.delegate back];
    }
}
@end
